package org.mao.base;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.mao.util.JsonDateSerializer;
import org.mao.util.JsonDateTimeSerializer;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

public abstract class BaseEntity {

	private Integer id;

	@JsonSerialize(using = JsonDateTimeSerializer.class)
	private Date createTime;

	private Integer createBy;

	@JsonSerialize(using = JsonDateSerializer.class)
	private Date updateTime;

	private Integer updateBy;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getCreateBy() {
		return createBy;
	}

	public void setCreateBy(Integer createBy) {
		this.createBy = createBy;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(Integer updateBy) {
		this.updateBy = updateBy;
	}
	
	protected String limitStringLength(String value, Integer length) {
		if (StringUtils.isNotBlank(value)) {
			if (value.length() > length) {
				value = value.substring(0, length);
			}
		}
		return value;
	}

}
